package private

import (
	v1 "code.bydev.io/cht/customer/kyc-stub.git/pkg/bybit/kyc/info/v1"
	"code.bydev.io/cht/customer/kyc_admin_service/internal/utils/middleware"
	"code.bydev.io/frameworks/byone/zrpc"
	"git.bybit.com/svc/stub/pkg/pb/api/kyc"
	"git.bybit.com/svc/stub/pkg/pb/api/user"
)

// RPCConfig rpc server连接配置信息，格式：domain+grpc service name+Access
type RPCConfig struct {
	CmdHub zrpc.CmdHubClientConf
	//UserServicePrivateAccess zrpc.RpcClientConf // 用户服务
	KycInternalClientAccess zrpc.RpcClientConf // KYC
}

// RPCClient rpc client，格式：domain+grpc service name, 如：财务ServiceOuterAPI-FinanceServiceOuterAPI
type RPCClient struct {
	UserServicePrivateAPI    user.MemberInternalClient
	KycInternalClientAPI     kyc.KycInternalClient
	KycInternalClientInfoAPI v1.InfoAPIClient
}

func InitRPC(rc *RPCConfig) *RPCClient {
	clientInterceptors := []zrpc.ClientOption{zrpc.WithUnaryClientInterceptor(middleware.LogClientInterceptor)}
	//rc.UserServicePrivateAccess.CmdHub = rc.CmdHub
	rc.KycInternalClientAccess.CmdHub = rc.CmdHub
	return &RPCClient{
		//UserServicePrivateAPI: user.NewMemberInternalClient(zrpc.MustNewClient(rc.UserServicePrivateAccess, clientInterceptors...).Conn()),
		KycInternalClientAPI:     kyc.NewKycInternalClient(zrpc.MustNewClient(rc.KycInternalClientAccess, clientInterceptors...).Conn()),
		KycInternalClientInfoAPI: v1.NewInfoAPIClient(zrpc.MustNewClient(rc.KycInternalClientAccess, clientInterceptors...).Conn()),
	}
}
